package com.cf.r1003_ak;

import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class f {

    static int[] a;
    static List<List<Integer>> graph;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken(); int t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken(); int n = (int) in.nval;
            a = new int[n];
            for (int i = 0; i < n; i++) {
                in.nextToken();
                a[i] = (int) in.nval - 1;
            }
            graph = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                graph.add(new ArrayList<>());
            }
            for (int i = 0; i < n - 1; i++) {
                in.nextToken(); int x = (int) in.nval - 1;
                in.nextToken(); int y = (int) in.nval - 1;
                graph.get(x).add(y);
                graph.get(y).add(x);
            }
            int[] ans = new int[n];
            dfs(0, -1, ans);
            for (int x : ans) {
                out.print(x);
            }
            out.println();
        }
        out.close();
        out.close();
        br.close();
    }

    public static void dfs(int cur, int fa, int[] ans) {
        Set<Integer> visited = new HashSet<>();
        if (fa != -1) {
            visited.add(a[fa]);
        }
        for (int x : graph.get(cur)) {
            if (x == fa) continue;
            if (a[cur] == a[x]) ans[a[cur]] = 1;
            if (visited.contains(a[x])) ans[a[x]] = 1;
            else visited.add(a[x]);
            dfs(x, cur, ans);
        }
    }

}
